﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<!-- The instances of the RelItem class will be stored in the "ItemRel" table -->
<class name="NCommet.Core.RelItem, NCommet.Core" table="ItemRel" lazy="false">
	
  <!-- Composite Identity -->
  <composite-id>
    <!-- Field "owner": Many-to-One association between RelItems and their subject item. -->
    <key-many-to-one
      name="owner" access="field"
      column="subject_item_id"
      class="NCommet.Core.Item, NCommet.Core" />

    <!-- Field "relative": Many-to-One association between RelItems and their object item. -->
    <key-many-to-one
      name="relative" access="field"
      column="object_item_id"
      class="NCommet.Core.Item, NCommet.Core" />

	<!-- Field "relationType" -->
	<key-property
      name="relationType" access="field"
      column="RelationType" type="String" length="50" />
  </composite-id>
	
  <!-- Field "dttm" -->
  <timestamp access="field" column="dttm" name="dttm" />

  <!-- Reinforce the Many-to-One association between RelItems and their subject item. -->
  <many-to-one
    name="Owner" access="property"
    column="subject_item_id"  not-null="true"
    class="NCommet.Core.Item, NCommet.Core"
    cascade="save-update" insert="false" update="false" />

  <!-- Reinforce the Many-to-One association between RelItems and their object item. -->
  <many-to-one
    name="Relative" access="property"
    column="object_item_id" not-null="true"
    class="NCommet.Core.Item, NCommet.Core"
    cascade="save-update" insert="false" update="false" />
</class>
</hibernate-mapping>